﻿namespace MiddlewareTestWebApp
{
    public class NotFoundMiddleware
    {
        private readonly RequestDelegate _next;

        public NotFoundMiddleware(RequestDelegate next)
        {
            _next = next;
        }

        public async Task InvokeAsync(HttpContext context)
        {
            context.Response.StatusCode = 404;
            context.Response.ContentType = "text/html;charset=utf-8";
            await context.Response.WriteAsync("<h1>404 Not Found 请求来到了一片未知的荒原</h1>");
        }
    }
}
